<%@ page import="news.util.PageBean" %>
<%@ page import="news.newsmain.entity.NewsPublish" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<style>
</style>

<h3>添加新闻</h3>
<div>
    <form method="post" enctype="multipart/form-data" action="/MainNews?oper=addMainNews">
        <label>主题</label>
        <select name="topid">
            <option value="1">国际</option>
            <option value="2">国内</option>
        </select>
        <br>
        <label>标题</label>
        <input type="text" name="title"/>
        <br>
        <label>作者</label>
        <input type="text" name="username"/>
        <br>
        <label>摘要</label>
        <textarea name="des" rows="5" cols="5">

        </textarea>
        <br>
        <label>内容</label>
        <textarea name="content" rows="15" cols="15">
        </textarea>
        <br>
        <input type="file" name="filename"/>
        <br>
        <input type="submit" name="submit" value="提交"/>
        <input type="submit" name="submit" value="重置"/>
    </form>
</div>

<script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: "${ctx}/TopicController?oper=getNewsTopicList",
            data: "k1:v1",
            dataType: "json",//预期服务器返回的数据类型。"json": 返回 JSON 数据 。
            success: function(msg){
                let topicRes = '<option value="">请选择...</option>';
                $.each( msg, function(i, item){
                    topicRes += '<option value="'+item.id+'">'+item.topicName+'</option>'
                });
                $("select[name='topid']").html(topicRes);
                // $("#topid").html(topicRes);
            }
        });
    });
</script>